package neuronvisualizer;

import com.threed.jpct.Object3D;
import com.threed.jpct.SimpleVector;

public class Highlight extends Object3D {
	private int layer;
	private int layerSize;
	private int[] layerSizes = {400,200,600,600};
	private int column;
	private int depth;
	
	private Driver parent;
	
	public Highlight(){
		super(12);
	}
	
	public Highlight(Driver p,int l,int c,int d){
		super(12);
		parent = p;
		layer = l;
		column = c;
		depth = d;
		
		System.out.println(""+parent.getMaxY()+" "+parent.getMinY());
		
		setTransparency(0);
        setLighting(Object3D.LIGHTING_NO_LIGHTS);
        setTransparencyMode(Object3D.TRANSPARENCY_MODE_ADD);
        setCulling(false);
        
		createBox();
		build();
	}
	
	public void createBox(){
		layerSize = (int)(layerSizes[layer]*parent.getScale());
		
		int startY = 0;
		if(layer>0){
			for(int i=0;i<layer;i++){
				startY+=layerSizes[i]*parent.getScale();
			}
		}
		float colWidth = 400*parent.getScale();
		
		SimpleVector a1 = new SimpleVector((column-1)*colWidth,parent.getMaxY()+startY,parent.getMinZ());
		SimpleVector b1 = new SimpleVector((column-1)*colWidth,parent.getMaxY()+startY+layerSize,parent.getMinZ());
		SimpleVector c1 = new SimpleVector(column*colWidth,parent.getMaxY()+startY,parent.getMinZ());
		SimpleVector d1 = new SimpleVector(column*colWidth,parent.getMaxY()+startY+layerSize,parent.getMinZ());

		SimpleVector a2 = new SimpleVector((column-1)*colWidth,parent.getMaxY()+startY,parent.getMinZ()+depth);
		SimpleVector b2 = new SimpleVector((column-1)*colWidth,parent.getMaxY()+startY+layerSize,parent.getMinZ()+depth);
		SimpleVector c2 = new SimpleVector(column*colWidth,parent.getMaxY()+startY,parent.getMinZ()+depth);
		SimpleVector d2 = new SimpleVector(column*colWidth,parent.getMaxY()+startY+layerSize,parent.getMinZ()+depth);

		addTriangle(a1,b1,c1);
		addTriangle(b1,c1,d1);
		addTriangle(a2,b2,c2);
		addTriangle(b2,c2,d2);
		addTriangle(a1,b1,b2);
		addTriangle(a1,a2,b2);
		addTriangle(c1,d1,c2);
		addTriangle(d1,c2,d2);
		addTriangle(a1,a2,c1);
		addTriangle(a2,c2,c1);
		addTriangle(b1,b2,d1);
		addTriangle(b2,d2,d1);
	}
	
	public int getLayer(){
		return layer;
	}
	
	public void setLayer(int l){
		layer = l;
	}
	
	public int getColumn(){
		return column;
	}
	
	public void setColumn(int c){
		column = c;
	}
	
	public int getDepth(){
		return depth;
	}
	
	public void setDepth(int d){
		depth = d;
	}
	
}
